package com.mybatis.quartz.job;

import com.sun.javaws.exceptions.ErrorCodeResponseException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.File;
import java.io.FileNotFoundException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Slf4j
@Component
@EnableScheduling
public class SpringJob {



    //表示每天0时0分0秒执行 删除过期文件
    @Scheduled(cron = "0/2 * * * * ?")
    public void deleteJob() {
        log.debug("Spring开始定时任务:"+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+"线程名字："+Thread.currentThread().getName());
        try {
        Thread.sleep(8000);
        }catch (Exception e){
            e.printStackTrace();
        }
        log.debug("Spring结束定时任务:"+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+"线程名字："+Thread.currentThread().getName());
    }


}
